<?php
/**
 * Medical Center as a Partner of a Medical Study Object
 * Load from the Dao and return the Object corresponding to msid passed id
 * if nothing is found it will redirect to the home page with an error
 *
 * @author Xavier VILAIN
 * @package \Nawa\MedicalStudy\MedicalCenter
 *
 */

use Nawa\MedicalStudy;

$xview = Xview::instance();
$msid = $xview->val('msid');
if(empty($msid))
{
	$xview->accessDenied();
}
$mcid = $xview->val('mcid');
if(empty($mcid))
{
	$xview->accessDenied();
}
try {
	$ms = \Fox\Dao::load(MedicalStudy::className(),$msid);
	$mc = $ms->findMedicalCentersPartners($msid.':'.$mcid);
	if(empty($mc) || !$mc->exists())
	{
		$xview->accessDenied();
	}
	return $mc;
}
catch (Fox\Object\Exception\NotExist $e)
{
	$xview->accessDenied();
}